package com.bcx.crm.spring_boot.springMVC.fileUpload;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

/**
 * Created by ys on 2018/4/22.
 * MultipartResolver配置(也可在springMVC的xml配置文件中配置)
 *  1.上传文件大小上限，单位为字节（10MB）
 *  2.请求的编码格式，必须和jSP的pageEncoding属性一致，以便正确读取表单的内容，默认为ISO-8859-1
 */
@Configuration
public class UploadConfig {
    @Bean
    public MultipartResolver multipartResolver(){
        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
        multipartResolver.setMaxUploadSize(10485760); //1.
        multipartResolver.setDefaultEncoding("UTF-8");  //2.
        return multipartResolver;
    }
}
